﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using YEngineLib;
using YEngineLib.Animation;

namespace Spyfall.Objects
{
    class Currency : Object
    {
        public Texture2D texture;
        public Vector2 position;
        public Vector2 velocity;

        public Currency()
        {
            ObjectID = Object_Type.CURRENCY;
        }

        public void Initialize(Texture2D pTexture, float pPositionX, float pPositionY, float pVelocityX, float pVelocityY)
        {
            texture = pTexture;
            position.X = pPositionX;
            position.Y = pPositionY;
            velocity.X = pVelocityX;
            velocity.Y = pVelocityY;

            ColRect = new Rectangle((int)position.X, (int)position.Y, this.texture.Width, this.texture.Height / 3);
        }

        public override void Update(float deltaTime)
        {
            position.Y += (velocity.Y * deltaTime);
            ColRect = new Rectangle((int)position.X, (int)position.Y, this.texture.Width, this.texture.Height / 3);
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            YEngine.Graphics.SpriteBatch.Draw(texture, position, Color.White);

            // draw collision rects
            Texture2D dummyTexture;
            Rectangle dummyRectangle;
            dummyRectangle = this.ColRect;
            dummyTexture = new Texture2D(YEngine.Game.GraphicsDevice, 1, 1);
            dummyTexture.SetData(new Color[] { Color.White });

            YEngine.Graphics.SpriteBatch.Draw(dummyTexture, dummyRectangle, Color.White);
        }

        public override bool Collide(Object tar)
        {
            return ColRect.Intersects(tar.ColRect);
        }
    }
}
